package com.xinruke.hostels.systemmanage.controller;

import com.xinruke.hostels.common.controller.BaseController;
import com.xinruke.hostels.common.vo.ResultVO;
import com.xinruke.hostels.common.vo.query.RowsDataVO;
import com.xinruke.hostels.system.manage.interfaces.dto.*;
import com.xinruke.hostels.systemmanage.service.RestaurantService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 餐厅维护
 *
 * @author Jinz
 * @date 2019-06-27 1:25
 */
@RestController
@RequestMapping("/restaurant")
@Api(tags = "餐厅")
public class RestaurantController extends BaseController {
    @Autowired
    private RestaurantService restaurantService;

    @PostMapping("/add")
    @ApiOperation("添加餐厅")
    public ResultVO add(@Valid @RequestBody RestaurantAddDTO restaurantAddQueryDTO) {
        return restaurantService.add(restaurantAddQueryDTO);
    }

    @PostMapping("/modify")
    @ApiOperation("修改餐厅")
    public ResultVO modify(@Valid @RequestBody RestaurantUpdateDTO restaurantUpdateQueryDTO) {
        return restaurantService.modify(restaurantUpdateQueryDTO);
    }

    @PostMapping("/del")
    @ApiOperation("删除餐厅")
    public ResultVO delete(@Valid @RequestBody RestaurantDelDTO restaurantDelQueryDTO) {
        return restaurantService.delete(restaurantDelQueryDTO);
    }

    @PostMapping("/detail")
    @ApiOperation("餐厅详情")
    public ResultVO<RestaurantDetailQueryResultDTO> detail(@Valid @RequestBody RestaurantDetailQueryDTO restaurantDetailQueryDTO) {
        return restaurantService.detail(restaurantDetailQueryDTO);
    }

    @PostMapping("/restaurants")
    @ApiOperation("餐厅列表")
    public ResultVO<RowsDataVO<RestaurantDetailQueryResultDTO>> restaurants(@Valid @RequestBody RestaurantsQueryDTO restaurantsQueryDTO) {
        return restaurantService.restaurants(restaurantsQueryDTO);
    }

    @PostMapping("/reservation/restaurants")
    @ApiOperation("预订系统下餐厅列表")
    public ResultVO<RowsDataVO<ReservationRestaurantQueryResultDTO>> restaurants(@Valid @RequestBody ReservationRestaurantQueryDTO restaurantsQueryDTO) {
        return restaurantService.reservationRestaurants(restaurantsQueryDTO);
    }

    /**
     * 获取会场未使用集合
     *
     * @return
     */
    @PostMapping("/getUnusedList")
    @ApiOperation(value = "获取餐桌未使用集合")
    public ResultVO<RowsDataVO<RestaurantUnusedQueryResultDTO>> getRoomUnusedList(@Valid @RequestBody RestaurantUnusedQueryDTO entity) {
        ResultVO<RowsDataVO<RestaurantUnusedQueryResultDTO>> resultVO = ResultVO.fail();
        RowsDataVO<RestaurantUnusedQueryResultDTO> rowsDataVO = restaurantService.getRestaurantUnusedList(entity);
        resultVO.setCode(ResultVO.SUCCESS);
        resultVO.setMessage("SUCCESS");
        resultVO.setData(rowsDataVO);
        return resultVO;
    }
}
